// Requires Model to be loaded first
// View-relate

function View_init()
{
    View_source();
    View_addSaveNotice();
}

function View_source()
{
    $$('.sl').each(function (elmt){
        View_addClicker(elmt);
    });
}

function View_addClicker(elmt)
{
    var buttonClicker = document.createElement('img');
    if(elmt.hasClassName('hasNote'))
        buttonClicker.setAttribute('src',  sUBoatHome + 'attach.png');
    else
        buttonClicker.setAttribute('src',  sUBoatHome + 'code.png');

    buttonClicker.addClassName('slclicker'); 
    buttonClicker.addClassName('view');
    buttonClicker.addClassName('clicker'); // For IE :(
    buttonClicker.setAttribute('title',  'Click for menu. Double-click line content to add comment.');

    elmt.insert({before:buttonClicker});
}

function View_setClickerSource(elmt){
    if(elmt.hasClassName('hasNote'))
        elmt.previous(0).setAttribute('src',  sUBoatHome + 'attach.png');
    else
        elmt.previous(0).setAttribute('src',  sUBoatHome + 'code.png');
}

function View_addSaveNotice(){
    var savenotice = document.createElement('span');
    savenotice.id = 'SaveNotice';
    savenotice.addClassName('view')
    $('DocFilename').insert({after:savenotice});

    if(!(Prototype.Browser.Gecko | Prototype.Browser.IE)){
       $('SaveNotice').insert({after:" - Save supported only for Firefox & IE."});
    }
}

function View_remove(){

}


function View_restore(){
    View_source();
    View_addSaveNotice();
}